var e = new(require("../../utils/http").HTTP)();
let {
  getTaskInfo,
  getProjectList
} = require("../../api/programs/forward");
let {
  getNoTask
} = require("../../api/attract/select");

Page({
  data: {
    zyList: [{
      'name': '资源库',
      'imgUrl': '/icon/dbrw.png',
      id: "1",
    },
  ],
    navBtn: [{
      name: "当日待办",
      id: "1"
    }, {
      name: "完善信息",
      id: "3"
    },{
      name: "访客计划",
      id: "2"
    },  {
      name: "遗忘提醒",
      id: "4"
    }],
    navNum: [{
      num: "0",
      id: "1"
    }, {
      num: "0",
      id: "3"
    },{
      num: "0",
      id: "2"
    }, {
      num: "0",
      id: "4"
    }],
    Nrybh: "",
    right_icon: 0,
    indicatorDots: !0,
    autoplay: !0,
    myId: null,
    myName: null,
    interval: 3e3,
    duration: 800,
    myID: "",
    myName: "",
    Nrybh: "",
    projectList: [{
        name: "新增项目",
        imgUrl: "/icon/newIcon/xz.png",
        id: "1",
        type: 1,
      },
      {
        name: "项目任务",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/反馈.png",
        id: "6",
        type: 77,
      },
      {
        name: "我的项目",
        imgUrl: "/icon/newIcon/wode.png",
        id: "7",
        type: 99,
      },
      {
        name: "问题反馈",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/问题反馈.png",
        id: "2",
      },
    ],

    courtship: [
      // {
      //   name: "待办任务",
      //   imgUrl: "/icon/dbrw.png",
      //   id: "10",
      // },
      {
        name: "新增客户",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/新增客户.png",
        id: "1",
      },
      {
        name: "我的客户",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/我的客户.png",
        id: "3",
      },
      {
        name: "跟进记录",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/跟进记录.png",
        id: "7",
      },
      {
        name: "关注客户",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/关注客户.png",
        id: "6",
      },
      {
        name: "意向客户",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/意向客户.jpg",
        id: "2",
      },
      {
        name: "重点客户",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/重点客户.jpg",
        id: "4",
      },
      {
        name: "公海池",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/公海池.png",
        id: "5",
      },
      {
        name: "联系人",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/我的渠道.png",
        id: "8",
      },
      {
        name: "外部对接客户",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/项目.png",
        id: "9",
      },
    ],
    serve: [{
        name: "空房",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/空房.png",
        id: "1",
      },
      {
        name: "已出租",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/已出租.jpg",
        id: "2",
      },
      {
        name: "预定",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/预定.png",
        id: "3",
      },
      {
        name: "预退租",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/预退租.png",
        id: "4",
      },
    ],
    park: [{
        name: "新增渠道",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/新增渠道.png",
        id: "1",
      },
      {
        name: "项目渠道",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/项目渠道.png",
        id: "2",
      },
      {
        name: "我的渠道",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/渠道.png",
        id: "3",
      },
    ],
    problem: [{
        name: "问题反馈",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/问题反馈.png",
        id: "1",
      },
      {
        name: "反馈处理",
        imgUrl: "https://www.qlsyyun.com:3000/images/图标/反馈.png",
        id: "2",
      },
    ],
    msgList: [{
        id: 1,
      },
      {
        id: 2,
      },
      {
        id: 3,
      },
      {
        id: 4,
      },
    ],
  },
  gozy(e){
    let {id}=e.currentTarget.dataset
    switch (id) {
      case '1':
        wx.navigateTo({
          url: '../slibrary_all/slibrary/slibrary',
        })
        break;
    
      default:
        break;
    }
  },
  exploit(e) {
    let {
      index
    } = e.currentTarget.dataset
    wx.navigateTo({
      url: `/pages/intention/notask/notask?id=${index}`,
    })
  },
  animationChange: function (e) {
    this.activeSlide = e.detail.current;
  },
  swiperChange: function (e) {
    this.setData({
      swiperCurrent: e.detail.current,
    });
  },
  detailClick: function (e) {
    wx.navigateTo({
      url: "/pages/list/listDetail/listDetail?listId=" +
        e.currentTarget.dataset.id +
        "&xm=" +
        e.currentTarget.dataset.xm,
    });
  },

  goPrograms(e) {
    let programId = e.currentTarget.dataset.id;
    let programName = e.currentTarget.dataset.name;
    switch (programId) {
      case "1":
        wx.navigateTo({
          url: `/pages/programs/add/add`,
        });
        break;
      case "2":
        wx.navigateTo({
          url: `/pages/programs/feedback/feedback`,
        });
        break;
      case "3":
        wx.navigateTo({
          url: `/pages/programs/feedback/list/list`,
        });
        break;
      case "6":
        wx.navigateTo({
          url: `/pages/programs/forward/forward`,
        });
        break;
      case "7":
        wx.navigateTo({
          url: `/pages/programs/forwardevauate/forwardevauate`,
        });
        break;
      default:
        break;
    }
  },
  manage: function (e) {
    console.log(e);
    var t = e.currentTarget.dataset.id,
      a = e.currentTarget.dataset.name;
    if ((a = "待办任务" && t == 10)) {
      wx.navigateTo({
        url: "/pages/intention/notask/notask",
      });
    }
    6 == t ?
      wx.navigateTo({
        url: "/pages/my/concern/concern",
      }) :
      1 == t ?
      wx.navigateTo({
        url: "/pages/intention/add/add",
      }) :
      wx.navigateTo({
        url: "/pages/intention/intention/intention?address=" + a + "&id=" + t,
      });
  },
  onShow: function () {
    wx.showLoading({
      title: "加载中",
    });

    let usesrInfo = wx.getStorageSync("userInfoMy");
    getNoTask(1, usesrInfo.jname, usesrInfo.bm).then(res => {
      this.setData({
        'navNum[0].num': res.data[0].rw1,
        'navNum[1].num': res.data[0].rw3,
        'navNum[2].num': res.data[0].rw2,
        'navNum[3].num': res.data[0].rw4,
      })
    })
    getTaskInfo({
      rwr: usesrInfo.jname,
      rybh: usesrInfo.rybh,
    }).then((res) => {
      if (res.length == 0 || res[0].rws == undefined) {
        this.setData({
          right_icon: 0,
        });
      } else {
        this.setData({
          right_icon: res[0].rws,
        });
      }
    });
  },
  onLoad: function () {
    let usesrInfo = wx.getStorageSync("userInfoMy");
    getNoTask(1, usesrInfo.jname, usesrInfo.bm).then(res => {
      this.setData({
        'navNum[0].num': res.data[0].rw1,
        'navNum[1].num': res.data[0].rw3,
        'navNum[2].num': res.data[0].rw2,
        'navNum[3].num': res.data[0].rw4,
      })
    })
    getTaskInfo({
      rwr: usesrInfo.jname,
      rybh: usesrInfo.rybh,
    }).then((res) => {
      if (res.length == 0 || res[0].rws == undefined) {
        this.setData({
          right_icon: 0,
        });
      } else {
        this.setData({
          right_icon: res[0].rws,
        });
      }

    });
    var t = this,
      a = wx.getStorageSync("user");
    this.setData({
      myId: a[11],
      myName: a[0],
    });

    e.request({
      url: `https://www.qlsyyun.com:3000/getUserInfo?name=${a[0]}`,
    }).then((res) => {
      console.log(res);
      if (res[0].bm !== a[1]) {
        wx.showToast({
          title: "个人信息存在更新，请重新登录",
          icon: "none",
          duration: 1500,
        });
        wx.removeStorageSync("user");
        wx.redirectTo({
          url: "pages/my/login/login",
        });
        return;
      }
    });
    e
      .request({
        url: "https://www.qlsyyun.com:3030/list",
        data: {
          arr: 1,
        },
      })
      .then(function (e) {
        t.setData({
          list: e.data,
        });
      }),
      e
      .request({
        url: "https://www.qlsyyun.com:3030/service/title",
        data: {
          id: t.data.msgList.length + 1,
        },
      })
      .then(function (e) {
        t.setData({
          msgList: e.data,
        });
      }),
      e
      .request({
        url: "https://www.qlsyyun.com:3030/login/record",
        header: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
        method: "POST",
        data: {
          name: a[0],
          bumen: a[1],
        },
      })
      .then(function (e) {});
  },
  // feedback: function (e) {
  //   var t = e.currentTarget.dataset.id;
  //   1 == t ? wx.navigateTo({
  //     url: "/pages/programs/feedback/feedback"
  //   }) : 2 == t ? wx.navigateTo({
  //     url: "/pages/programs/feedback/list/list"
  //   }) : wx.navigateTo({
  //     url: "/pages/mine/develop/develop"
  //   })
  // },
  housRental: function (t) {
    console.log(t.currentTarget.dataset, "e.currentTarget.dataset");
    var a = t.currentTarget.dataset.id,
      n = t.currentTarget.dataset.name;
    1 == a || 2 == a ?
      wx.navigateTo({
        url: "/pages/rental/rental/rental?address=" + n + "&id=" + a,
      }) :
      3 == a ?
      e
      .request({
        url: "https://www.qlsyyun.com:3000/reserve",
      })
      .then(function (e) {
        console.log(e.data, "data"),
          0 == e.data.length ?
          wx.showToast({
            title: "暂无预定房源",
            icon: "none",
            mask: !0,
          }) :
          wx.navigateTo({
            url: "/pages/rental/rental/rental?address=" + n + "&id=" + a,
          });
      }) :
      e
      .request({
        url: "https://www.qlsyyun.com:3000/throw",
      })
      .then(function (e) {
        0 == e.data.length ?
          wx.showToast({
            title: "暂无预退租房源",
            icon: "none",
            mask: !0,
          }) :
          wx.navigateTo({
            url: "/pages/rental/rental/rental?address=" + n + "&id=" + a,
          });
      });
  },
  development: function (e) {
    console.log(e.currentTarget.dataset.id, "e");
    var t = e.currentTarget.dataset.id;
    1 == t ?
      wx.navigateTo({
        url: "/pages/channel/addchannel/addchannel",
      }) :
      2 == t ?
      wx.navigateTo({
        url: "/pages/channel/channel/channel?id=" + t,
      }) :
      3 == t &&
      wx.navigateTo({
        url: "/pages/channel/mychannel/mychannel?id=" + t,
      });
  },
});